// pages/videocontentdeail/videocontentdeail.js
import {find} from "../../api/article"
import {find as productfind} from "../../api/product"
Page({

  /**
   * 页面的初始数据
   */
  data: {
    id:"",
    articlelist:{},
    productId:"",
    productList:{},
    article_content:''
  },
  togooddeta(){
    wx.navigateTo({
      url: '/pages/goods/product/details?id=' + this.data.productId
    })
  },
  navTo() {
    let p = getCurrentPages().length;
    if (p <= 1) {
      wx.switchTab({
        url: '/pages/index/index',
      })
    } else {
      wx.navigateBack({
        delta: 1
      })
    }
  },
  setNavSize: function () {
    var that = this,
      sysinfo = wx.getSystemInfoSync(),
      statusHeight = sysinfo.statusBarHeight,
      isiOS = sysinfo.system.indexOf('iOS') > -1,
      navHeight;
    console.log(sysinfo)
    if (!isiOS) {
      navHeight = 48;
    } else {
      navHeight = 44;
    }
    that.setData({
      status: statusHeight,
      navHeight: navHeight
    })
  },
  findclick(){
    find(this.data.id).then(res=>{
        console.log(res);
        this.data.articlelist=res.data.article
        this.setData({
          articlelist:this.data.articlelist,
          article_content:this.data.article_content
        })
    })
  },
  findproduct(){
    productfind(this.data.productId).then(res=>{
       this.data.productList=res.data.products[0]
       this.setData({
        productList:this.data.productList
       })
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
      this.setNavSize()
      console.log("85655965652645641534153153215313");
      console.log(options);
      this.data.id=options.id
      this.data.productId=options.productId
      this.findclick()
      this.findproduct()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})